export const defenderRun = (creep,sourcesIndex) => {
    workCore(creep)
}
const workCore = (creep) => {
    const target = creep.pos.findInRange(FIND_HOSTILE_CREEPS,3);
    if (target.length>0) {
        if (creep.rangedAttack(target[0]) === ERR_NOT_IN_RANGE) {
            creep.moveTo(target[0]);
        }
    }else {
        for (const roomsKey in Game.rooms) {
            const targets = Game.rooms[roomsKey].find(FIND_HOSTILE_CREEPS)
            if (targets.length>0) {
                if (creep.rangedAttack(targets[0]) === ERR_NOT_IN_RANGE) {
                    creep.moveTo(targets[0]);
                }
            }
        }
    }
}